// import axios from '../utils/axios'
import base from './base'

const module = 'menus'

export default {
  getList ({ cb, ecb, url, params }) {
    base.find({ cb, ecb, params, module: url })
  },
  create ({ cb, ecb, formData }) {
    base.create({ cb, ecb, formData, module })
  },
  update ({ cb, ecb, self, formData }) {
    base.update({ cb, ecb, self, formData })
  },
  remove ({ cb, ecb, self }) {
    base.remove({ cb, ecb, self })
  },
  delete ({ cb, ecb, idList }) {
    base.delete({ cb, ecb, idList, module })
  },
  changeParent ({ cb, ecb, parentSelf, parent }) {
    base.put({ cb, ecb, url: parent, data: parentSelf })
  },
  loadChildren ({ cb, ecb, self, params }) {
    base.query({
      url: `${self}/children`,
      params: {
        projection: 'MenuWithChildrenCount',
        sort: 'num',
        ...params
      },
      cb,
      ecb
    })
  }
}
